package com.yesun.task.pipeline.handler.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yesun.core.util.FileUtils;
import com.yesun.server.mdp.service.client.impl.DefaultClient;
import com.yesun.task.pipeline.common.Constant;
import com.yesun.task.pipeline.domain.dto.JobDto;
import com.yesun.task.pipeline.domain.dto.TaskDto;
import com.yesun.task.pipeline.handler.Executor;
import com.yesun.task.pipeline.handler.Handler;
import com.yesun.task.pipeline.handler.Loader;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;

//每日成交数据Handler，粒度股票+dt
@Slf4j
public class TestHandler extends Handler {


    public TestHandler(JobDto jobDto) {
        super(jobDto);
    }

    @Override
    public Loader getLoader() {
        log.info("Test Handler Loader...");
        return new Loader() {
            @Override
            public void load(BlockingQueue queue) {
                TaskDto taskDto = new TaskDto();
                taskDto.setJobName(jobDto.getJobName());
                taskDto.setName("Test采集任务");
                taskDto.setTag(Constant.JOB_TAG_TEST);
                queue.offer(taskDto);
                log.info("添加子任务：" + taskDto.getName());
            }
        };
    }

    @Override
    public Executor getExecutor() {
        return new Executor() {
            @Override
            public void execute(TaskDto taskDto) {
                //执行task的采集
                log.info("Test Handler Execute....");
            }
        };
    }
}
